package com.es.test;

import com.es.entity.IdCard;
import com.es.entity.Person;
import com.es.service.PersonService;
import com.es.service.impl.PersonServiceImpl;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

/**
 * 描述:
 * MyBatis-
 *
 * @author Derek
 * 创建时间：2022-05-09 9:50
 */
public class One2OneServlet {

    PersonService service = null;

    @Before
    public void getSqlSession(){
       service =  new PersonServiceImpl();
    }

    @Test
    public void insert(){
        IdCard idCard = new IdCard();
        idCard.setIdNo("370112200201025678");

        Person person = new Person();
        person.setName("李健");
        person.setIdCard(idCard);

        service.save(person);
    }

    @Test
    public void list(){
        System.out.println("编号：\t姓名\t身份证号");
        List<Person> personList = service.list();
        personList.forEach(p->{
            System.out.println(p.getId()+"\t"+p.getName()+"\t"+p.getIdCard().getIdNo());
        });
    }

    @Test
    public void get(){
        Person person = service.get(3);
        System.out.println(person);
    }
}
